<include file="Public:meta" />
<style>
.swiper-container{position:fixed;top:20px;left:0;right:0;bottom:0; z-index: -100; max-width: 750px;}
</style>
<include file="Public:cate_head" />
<div style="max-width: 750px; margin: 0 auto;">
<div class="listpanel">
	<div style="display:flex">
    <div class="scrollx mescroll-touch-x">
                <div id="scrollxContent" class="scrollx-content">
                    <ul id="nav" class="nav">
    <li i="0"><a href="{:U('cate/index')}{$trackurl}" class="menu-item <empty name="cid">active</empty>">全部商品</a></li>
    <volist name="catetree" id="tree" key="i">
     <li i="{$i}">
     <a class="menu-item <if condition="$cid eq $tree['id']">active</if>" href="{:U('cate/index',array('cid'=>$tree['id']))}{$trackurl}">{$tree.name}</a>
     </li>
      </volist>
    </ul>
                </div>
            </div>
<div class="cxx-more-cate" style="display: none;">
    <ul style="width:100%">	
    	<volist name="catetree" id="tree">
        <li data-id="{$i}"><a <if condition="$cid eq $tree['id']">class="am-btn am-btn-default am-round"</if> href="{:U('cate/index',array('cid'=>$tree['id']))}{$trackurl}"><span>{$tree.name}</span></a></li>
      </volist>
	    </ul>
</div>
<div class="cxx-transparent-bg"></div>  
    <div id="drop-down" class="drop-down" data-action="down"><i class="iconfont tqk-jiantou_down maincolor"></i></div>
    <div class="cate"></div>
   </div>
    
    <!-- filter -->
    <div class="filter">
        <div class="filter-item"><a href="{:U("ershi/index",array('cid'=>$cid,'sort'=>'new'))}?k={:urldecode($sokey)}">综合</a> <empty name="txt_sort"><i class="icon-caret down"></i></empty> <if condition='$txt_sort eq "new"'><i class="icon-caret down"></i></if></div>
        <div class="filter-item"><a href="{:U("ershi/index",array('cid'=>$cid,'sort'=>'hot'))}?k={:urldecode($sokey)}">月销量</a><if condition='$txt_sort eq "hot"'><i class="icon-caret down"></i></if></div>
        <div class="filter-item"><a href="{:U("ershi/index",array('cid'=>$cid,'sort'=>'rate'))}?k={:urldecode($sokey)}">大额券</a><if condition='$txt_sort eq "rate"'><i class="icon-caret down"></i></if></div>
        <div class="filter-item">
            <a href="{:U("ershi/index",array('cid'=>$cid,'sort'=>'price'))}?k={:urldecode($sokey)}">券后价</a><if condition='$txt_sort eq "price"'><i class="icon-caret down"></i></if>
        </div>
    </div>
</div>

<div id="swiper" class="swiper-container">
<div id="swiperWrapper" class="swiper-wrapper" >
<div id="mescroll" class="mescroll">

 <div class="goods-wrap">
 <div class="goods">
  <volist name='list' id="vo"> 
	<div class="goods-item">
					<a href="{$vo.linkurl}{$trackurl}">
	               <div class="goods-pic">
	                   <img src="{$vo.pic_url}_400x400.jpg" class="goods-pic">
	   <if condition="($visitor or $isfanli eq 0) and $isfanli neq 2">
	    <span class="share-info" >
	    	预计返￥ {:Rebate1($vo['coupon_price']*$vo['commission_rate']/10000)}</span>
	  </if>             
	               </div>
	               <div class="goods-info">
	                   <i class="icon-type  <if condition="$vo.shop_type eq 'B'">tmall<else/>taobao</if>"></i>
	                   <p class="goods-name ellipsis-2">{$vo.title}</p>
	               </div>
	               <div class="goods-mid">
	                   <p class="f-12 c-999">现价 ￥{$vo.price}</p>
	                   <p class="goods-share maincolor">
	                   	月销{$vo.volume}件
	                   </p>
	               </div>
	               <div class="goods-bot">
	                   <p class="f-12 c-111 lh-22">券后&nbsp;¥&nbsp;<span class="am-text-lg maincolor">{$vo.coupon_price}</span></p>
	                   <div class="goods-coupon">
	                       <p class="f-10 c-white">{$vo.quan}元券</p>
	                   </div>
	               </div>
					</a>
	            </div>
</volist>
</div>
<div id="dataList">
	
</div>
</div>


</div>
</div></div>
</div>
<include file="Public:footer" />
<tqkjs  href="__STATIC__/wap/js/jquery.min.js,__STATIC__/wap/js/amazeui.min.js"/>
<tqkjs  href="__STATIC__/wap/js/mescroll.min.js,__STATIC__/wap/js/swiper.min.js"/>
<script type="text/javascript">
var curNavDom;
var i=$('.active').parent().index('li');
$("#nav li").each(function(n,dom){
    if (dom.getAttribute("i")==i) {
        dom.classList.add("active");
        curNavDom=dom;
    } else{
        dom.classList.remove("active");
    }
});

var isFirst = true;
var issave=false;
var ispage=1;
var posname="pos_{$cid}_{$txt_sort}_{$sokey}_{:CONTROLLER_NAME}";
var htname="ht_{$cid}_{$txt_sort}_{$sokey}_{:CONTROLLER_NAME}";
var pgname="pg_{$cid}_{$txt_sort}_{$sokey}_{:CONTROLLER_NAME}";
var pgnum = parseInt(sessionStorage.getItem(pgname));
if(pgnum>0){
var pageIndex = pgnum;		
}else{
var pageIndex = 0;	
}
page = {num:1};
 
var mescroll = new MeScroll("mescroll", {
            up: {
                auto:false,
                callback: getListData,
                isBounce: false,
                hardwareClass:'mescroll-hardware',
                	warpClass: "mescroll-upwarp",
                clearEmptyId: "dataList",
                toTop:{ 
                    src : "__STATIC__/wap/images/icon/mescroll-totop.png",
                },
                onScroll:function(mescroll){
                <if condition="$isweixin">
                	if(isNaN(parseInt(sessionStorage.getItem(posname))) || issave){
                 var pos=mescroll.getScrollTop();
                 sessionStorage.setItem(posname,pos); 
                 var datahtml =$('#dataList').html();
                 sessionStorage.setItem(htname,datahtml);
                 issave = true; 
                 sessionStorage.setItem(pgname,ispage); 
                 }
                	</if>
                 
                }
            }
        });
        

var scrollxContent=document.getElementById("scrollxContent");
var star = scrollxContent.scrollLeft;
var end = curNavDom.offsetLeft + curNavDom.clientWidth/2 - document.body.clientWidth/2;
mescroll.getStep(star, end, function(step,timer){
scrollxContent.scrollLeft=step; 
});

  

    function getListData(page){
                getListDataFromNet(page.num+pageIndex,function(curPageData){
                    mescroll.endByPage(20, {$page_size});
                    setListData(curPageData);
                }, function(){
                    mescroll.endErr();
                });
            }
    function getListDataFromNet(pageNum,successCallback,errorCallback) {
             var ajaxurl="{:U('ershi/catelist',array('cid'=>$cid,'sort'=>$txt_sort))}";
                  ajaxurl=ajaxurl+"?k={$sokey}&p="+pageNum;
                  
                  ispage=pageNum;
                  
                    $.ajax({
                        type: 'GET',
                        url: ajaxurl,
                        dataType: 'html',
                        success: function(data){
                            successCallback(data);
                        },
                        error: errorCallback
                    });
         
            }
    

    
function setListData(curPageData){
                var listDom=document.getElementById("dataList");
                var liDom=document.createElement("div");
                liDom.className = 'goods';  
                liDom.innerHTML=curPageData;
                listDom.appendChild(liDom);
                
<if condition="$isweixin">             
 if(isFirst){ //如果存在缓存
 var tops = parseInt(sessionStorage.getItem(posname));
 var htmldata = sessionStorage.getItem(htname);
 if(htmldata){
 $('#dataList').html(htmldata);
 mescroll.scrollTo(tops,0);
 }
sessionStorage.removeItem(posname);
sessionStorage.removeItem(htname);
sessionStorage.removeItem(pgname);
sessionStorage.clear();
isFirst = false;
 }
 </if>
 
 
}



function jumpto(quan,num_id,quanurl,commission_rate){
      var num_id=num_id;
      var quan=quan;
      var quanurl=quanurl;
      var commission_rate = commission_rate;
      var trackurl='{$trackurl}';
      $.ajax({
        type:"post",
        data:{numid:num_id,quan:quan,quanurl:quanurl,commission_rate:commission_rate},
        url:"{:U('jumpto/jumpclick')}",
        dataType: 'json',
        success:function(json){
            if(json.status==1){
                window.location.href=json.urls+trackurl;
            }
        }
      });
    }
;$(function(){
    $('#drop-down, .drop-down').click(
    	function(){
    		var action = $('#drop-down, .drop-down').attr('data-action');
    		if(action == 'down'){
    			$('.drop-down i').attr({ class: "iconfont tqk-jiantou_up maincolor" });
    			$('.cxx-more-cate').slideDown('fast');
    			$('.cxx-transparent-bg').show();
    			$('#drop-down, .drop-down').attr('data-action','up');	
    		}
    		if(action == 'up'){
                $('.drop-down i').attr({ class: "iconfont tqk-jiantou_down maincolor" });
                $('.cxx-transparent-bg').hide();
    			$('.cxx-more-cate').slideUp('fast');
    			$('.cxx-transparent-bg').hide();
    			$('#drop-down, .drop-down').attr('data-action','down');
    		}		
    	}
    );
    $('.cxx-transparent-bg').on('click',function(){
        var action = $('#drop-down, .drop-down').attr('data-action');
        if(action == 'up'){
            $('.drop-down i').attr({ class: "iconfont tqk-jiantou_down maincolor" });
            $('.cxx-transparent-bg').hide();
            $('.cxx-more-cate').slideUp('fast');
            $('.cxx-transparent-bg').hide();
            $('#drop-down, .drop-down').attr('data-action','down');
        }
    	$('.cxx-transparent-bg').hide();	
    });
});
</script>
<include file="Public:stat" />
</body>
</html>
